import type { Metadata } from 'next'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import { EventEvidence } from '@/components/events/event-evidence'; import { EventList } from '@/components/events/event-row'; import { CountryChip, EventTypeBadge, ImportanceMeter, SignificanceBadge } from '@/components/ui/badges'; import { LiveAgo } from '@/components/ui/live'; import { Container, Note } from '@/components/ui/section'; import { api, ApiError, safe } from '@/lib/api'; import { fmtDateTime, fmtInt } from '@/lib/format'; import { routes, SITE_NAME } from '@/lib/site'; import type { EventDetail } from '@/lib/types'; export const revalidate = 120; async function load(id: string): Promise { try { return await api.event(id); } catch (e) { if (e instanceof ApiError && e.notFound) notFound(); throw e; } } export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise { const { id } = await params; const e = await safe(api.event(id)); if (!e) return { title: 'Event' }; return { title: e.title, description: e.summary ?? `${e.event_type} event detected for ${e.company.display_name} on ${fmtDateTime(e.detected_at)}.`, alternates: { canonical: `/events/${e.id}` }, openGraph: { title: `${e.title} | ${SITE_NAME}`, description: e.summary ?? undefined, type: 'article', publishedTime: e.detected_at }, robots: e.status === 'active' ? undefined : { index: false } }; } export default async function EventPage({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const e = await load(id); const related = await safe(api.companyEvents(e.company.slug, { per_page: 6 })); const others = (related?.items ?? []).filter((x) => x.id !== e.id).slice(0, 5); const jsonLd = { '@context': 'https://schema.org', '@type': 'NewsArticle', headline: e.title, datePublished: e.detected_at, dateModified: e.detected_at, about: { '@type': 'Organization', name: e.company.display_name, url: `https://${e.company.canonical_domain}` }, isBasedOn: e.source_url ?? undefined, publisher: { '@type': 'Organization', name: SITE_NAME } }; return (